import React, {useEffect, useState} from "react";
import {AntdMessage} from "./Message";
import {setIsCollapse} from "@/store/modules/userSlice.ts";
import {useDispatch} from "react-redux";


/**
 * 其他操作放在这里
 * @constructor
 */
export default function OtherOP({children}: any) {

    // 监控屏幕宽度
    const dispatch = useDispatch()
    const [width, setWidth] = useState(window.innerWidth);
    useEffect(() => {
        window.onresize = () => {
            setWidth(window.innerWidth)
        }
        if (width < 900) {
            dispatch(setIsCollapse(true))
        }
    }, [width])

    return (
        <>
            {/*全局的 Message 注入*/}
            <AntdMessage></AntdMessage>
            {children}
        </>
    )
}

